/**
 * author: abid.hussain
 */
exports.GACommonModel = Core.Class.subclass({
	classname : 'GACommonModel',
	initialize : function (){
		this.udid= null;
		this.device_type= null;
		this.device_model= null;
		this.device_os= null;
		this.game_family_id= null;
		this.game_family= null;
		this.game= null;
		this.game_id= null;
		this.game_flavor= null;
		this.game_version= null;
		this.ts= null;
		this.auth= null;
		this.is_error = "0";
		this.trans_list = [];
		this.events_list = [];
		this.c_offers_list = [];
	},
	
	setCommonParams : function ()
	{
		this.udid = GAConfigurations.getUdid();
		this._authenticateData(this.udid);
		this.device_type = GAConfigurations.getDeviceType();
		this._authenticateData(this.device_type);
		this.device_model = GAConfigurations.getDeviceName();
		this._authenticateData(this.device_model);
		this.device_os = GAConfigurations.getOsVersion();
		this._authenticateData(this.device_os);
		this.game_family_id = GAConfigurations.getGameFamilyId();
		this._authenticateData(this.game_family_id);
		this.game_family = GAConfigurations.getGameFamily();
		this._authenticateData(this.game_family);
		this.game =GAConfigurations.getGameName();
		this._authenticateData(this.game);
		var responseObject = GAGameLoader.getResponseObject();
		if(responseObject != null)
		{
			this.game_id = responseObject.getGameId();
		}
		this._authenticateData(this.game_id);
		this.game_flavor = GAConfigurations.getGameCode();
		this._authenticateData(this.game_flavor);
		this.game_version = GAConfigurations.getGameVersion();
		this._authenticateData(this.game_version);
		this.ts = this.getunixtimestamp();
		this._authenticateData(this.ts);
		var str = this.udid+this.game_family+this.game+this.ts;
		this.auth = Core.toMD5(str);
		this._authenticateData(this.auth);
	},
	
	getunixtimestamp : function()
	{
		var d = new Date();
		var localTime = d.getTime();
		var localOffset = d.getTimezoneOffset() * 60000;
		var utc = localTime + localOffset;
		var returnAble = Math.round(utc / 1000);
		
        return returnAble;
	},
	setTransactions : function (trans){
		this.trans_list = trans;
	},
	setOffers : function (offers){
		this.c_offers_list = offers;
	},
	setEvents : function (events){
		this.events_list = events;
	},
	_authenticateData: function(data){
		if(data == null || data ==""){
			data = "";
			this.is_error = "1";
		}
	},
	destroy: function(){
		delete this.trans_list;
		delete this.c_offers_list;
		delete this.events_list;
		this.udid= null;
		this.device_type= null;
		this.device_model= null;
		this.device_os= null;
		this.game_family_id= null;
		this.game_family= null;
		this.game= null;
		this.game_id= null;
		this.game_flavor= null;
		this.game_version= null;
		this.ts= null;
		this.auth= null;
		this.is_error = null;
	}
});
	